$(function(){
	bubbleMap();
	pieMap();
	stackedMap();
// 	/*forceGuide();*/
});
// 自动执行
function bubbleMap(){
	$.ajax({
        url:'policy_getBubbleData.action',
        type:'get',
        dataType : 'json',
        success:function(result){
		var policyBubble = echarts.init(document.getElementById('policyBubble'));
		policyBubble.title = '气泡图';
		var data =  result
		var bubbleOption = {
			    backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{
			        offset: 0,
			        color: '#f7f8fa'
			    }, {
			        offset: 1,
			        color: '#f7f8fa'
			    }]),
			    title: {
			        text: '政策文件阅读量'
			    },
			    legend: {
			        right: 10,
			        data: ['2018', '2019']
			    },
			    xAxis: {
			    	 type:'category',
			    	 //强制显示所有标签
			    	axisLabel:{
			            interval:0,
			            rotate:40,
			          },
			    	data:['综合类','创业扶持','市场/行业准入','企业减负','公共服务','技术创新','知识产权','技术改造','数字化转型','投融资','信用担保'],
			        splitLine: {
			            lineStyle: {
			                type: 'dashed'
			            }
			        }
			    },
			    yAxis: {
			        splitLine: {
			            lineStyle: {
			                type: 'dashed'
			            }
			        },
			        scale: true
			    },
			    series: [{
			        name: '2018',
			        data: data[0],
			        type: 'scatter',
			        symbolSize: function (data) {
			            return Math.sqrt(data[2]) / 5e2;
			        },
			        label: {
			            emphasis: {
			                show: true,
			                formatter: function (param) {
			                    return param.data[3];
			                },
			                position: 'top'
			            }
			        },
			        itemStyle: {
			            normal: {
			                shadowBlur: 10,
			                shadowColor: 'rgba(120, 36, 50, 0.5)',
			                shadowOffsetY: 5,
			                color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
			                    offset: 0,
			                    /*color: 'rgb(251, 118, 123)'*/
			                    color: '#c12e34'
			                }, {
			                    offset: 1,
			                    color: 'rgb(204, 46, 72)'
			                }])
			            }
			        }
			    }, {
			        name: '2019',
			        data: data[1],
			        type: 'scatter',
			        symbolSize: function (data) {
			            return Math.sqrt(data[2]) / 5e2;
			        },
			        label: {
			            emphasis: {
			                show: true,
			                formatter: function (param) {
			                    return param.data[3];
			                },
			                position: 'top'
			            }
			        },
			        itemStyle: {
			            normal: {
			                shadowBlur: 10,
			                shadowColor: 'rgba(25, 100, 150, 0.5)',
			                shadowOffsetY: 5,
			                color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
			                    offset: 0,
			                    color: '#e6b600'
			                }, {
			                    offset: 1,
			                    color: '#e6b600'
			                }])
			            }
			        }
			    }]
		};
	policyBubble.setOption(bubbleOption);
        }
	});
}


function pieMap(){
		$.ajax({
        url:'policy_getSubNum.action',
        type:'get',
        dataType : 'json',
        success:function(result){
        	var policyPie = echarts.init(document.getElementById('policyPie'));
        	policyPie.title = '饼状图';
        	pieOption = {
        			 color: [
        		            "#c12e34",
        		            "#e6b600",
        		            "#EE5C42",
        		            "#005eaa",
        		            "#2b821d",
        		            "#0098d9",
        		            "#00BFFF",
        		            "#32a487",

        		        	"#339ca8",
        		        	"#00C5CD",
        		        	"#76EEC6",
        		        	"#ADD8E6",
        		        	"#8DB6CD",
        		        	"#AAAAAA",

        		        ],
        		backgroundColor:'#f7f8fa',
        		line: {
                    itemStyle: {
                        normal: {
                            borderWidth: 1
                        }
                    },
                    lineStyle: {
                        normal: {
                            width: 2
                        }
                    },
                    symbolSize: 4,
                    symbol: "emptyCircle",
                    smooth: false
        			},
        			radar: {
        	            itemStyle: {
        	                normal: {
        	                    borderWidth: 1
        	                }
        	            },
        	            lineStyle: {
        	                normal: {
        	                    width: 2
        	                }
        	            },
        	            symbolSize: 4,
        	            symbol: "emptyCircle",
        	            smooth: false
        	        },
        	        bar: {
        	            itemStyle: {
        	                normal: {
        	                    barBorderWidth: 0,
        	                    barBorderColor: "#ccc"
        	                },
        	                emphasis: {
        	                    barBorderWidth: 0,
        	                    barBorderColor: "#ccc"
        	                }
        	            }
        	        },
        	        parallel: {
        	            itemStyle: {
        	                normal: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                },
        	                emphasis: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                }
        	            }
        	        },
        	        sankey: {
        	            itemStyle: {
        	                normal: {
        	                   borderWidth: 0,
        	                    borderColor: "#ccc"
        	                },
        	                emphasis: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                }
        	            }
        	        },
        	        funnel: {
        	            itemStyle: {
        	               normal: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                },
        	                emphasis: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                }
        	            }
        	        },
        	        gauge: {
        	            itemStyle: {
        	                normal: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                },
        	                emphasis: {
        	                   borderWidth: 0,
        	                   borderColor: "#ccc"
        	                }
        	            }
        	        },
        	        candlestick: {
        	            itemStyle: {
        	                normal: {
        	                    color: "#c12e34",
        	                    color0: "#2b821d",
        	                    borderColor: "#c12e34",
        	                    borderColor0: "#2b821d",
        	                    borderWidth: 1
        	                }
        	            }
        	        },
        	        graph: {
        	            itemStyle: {
        	                normal: {
        	                    borderWidth: 0,
        	                    borderColor: "#ccc"
        	                }
        	            },
        	            lineStyle: {
        	                normal: {
        	                    width: 1,
        	                    color: "#aaa"
        	                }
        	            },
        	            symbolSize: 4,
        	            symbol: "emptyCircle",
        	            smooth: false,
        	            color: [
        	                "#c12e34",
        	                "#e6b600",
        	                "#0098d9",
        	                "#2b821d",
        	                "#005eaa",
        	                "#339ca8",
        	                "#cda819",
        	                "#32a487"
        	            ],
        	            label: {
        	                normal: {
        	                    textStyle: {
        	                        color: "#eee"
        	                    }
        	                }
        	            }
        	        },
        	        map: {
        	            itemStyle: {
        	                normal: {
        	                    areaColor: "#dddddd",
        	                    borderColor: "#eeeeee",
        	                    borderWidth: 0.5
        	                },
        	                emphasis: {
        	                    areaColor: "rgba(230,182,0,1)",
        	                    borderColor: "#dddddd",
        	                    borderWidth: 1
        	                }
        	            },
        	            label: {
        	                normal: {
        	                    textStyle: {
        	                        color: "#c12e34"
        	                    }
        	                },
        	                emphasis: {
        	                    textStyle: {
        	                        color: "rgb(193,46,52)"
        	                    }
        	                }
        	            }
        	        },
        	        geo: {
        	            itemStyle: {
        	                normal: {
        	                    areaColor: "#dddddd",
        	                    borderColor: "#eeeeee",
        	                    borderWidth: 0.5
        	                },
        	                emphasis: {
        	                    areaColor: "rgba(230,182,0,1)",
        	                    borderColor: "#dddddd",
        	                    borderWidth: 1
        	                }
        	            },
        	            label: {
        	                normal: {
        	                    textStyle: {
        	                        color: "#c12e34"
        	                    }
        	                },
        	                emphasis: {
        	                    textStyle: {
        	                        color: "rgb(193,46,52)"
        	                    }
        	                }
        	            }
        	        },
        	        categoryAxis: {
        	            axisLine: {
        	                show: true,
        	                lineStyle: {
        	                    "color": "#333"
        	                }
        	            },
        	            "axisTick": {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            "axisLabel": {
        	                "show": true,
        	                "textStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            "splitLine": {
        	                "show": false,
        	                "lineStyle": {
        	                    "color": [
        	                        "#ccc"
        	                    ]
        	                }
        	            },
        	            splitArea: {
        	                "show": false,
        	                "areaStyle": {
        	                    "color": [
        	                        "rgba(250,250,250,0.3)",
        	                        "rgba(200,200,200,0.3)"
        	                    ]
        	                }
        	            }
        	        },
        	        valueAxis: {
        	            "axisLine": {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisTick: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisLabel: {
        	                "show": true,
        	                "textStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            splitLine: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": [
        	                        "#ccc"
        	                    ]
        	                }
        	            },
        	            splitArea: {
        	                "show": false,
        	                "areaStyle": {
        	                    "color": [
        	                        "rgba(250,250,250,0.3)",
        	                        "rgba(200,200,200,0.3)"
        	                    ]
        	                }
        	            }
        	        },
        	        logAxis: {
        	            "axisLine": {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisTick: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisLabel: {
        	                "show": true,
        	                "textStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            splitLine: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": [
        	                        "#ccc"
        	                    ]
        	                }
        	            },
        	            splitArea: {
        	                "show": false,
        	                "areaStyle": {
        	                    "color": [
        	                        "rgba(250,250,250,0.3)",
        	                        "rgba(200,200,200,0.3)"
        	                    ]
        	                }
        	            }
        	        },
        	        timeAxis: {
        	            "axisLine": {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisTick: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            axisLabel: {
        	                "show": true,
        	                "textStyle": {
        	                    "color": "#333"
        	                }
        	            },
        	            splitLine: {
        	                "show": true,
        	                "lineStyle": {
        	                    "color": [
        	                        "#ccc"
        	                    ]
        	                }
        	            },
        	            splitArea: {
        	                "show": false,
        	                "areaStyle": {
        	                    "color": [
        	                        "rgba(250,250,250,0.3)",
        	                        "rgba(200,200,200,0.3)"
        	                    ]
        	                }
        	            }
        	        },
        	        toolbox: {
        	            "iconStyle": {
        	                "normal": {
        	                    "borderColor": "#06467c"
        	                },
        	                "emphasis": {
        	                    "borderColor": "#4187c2"
        	                }
        	            }
        	        },
        	        tooltip: {
        	            "axisPointer": {
        	                "lineStyle": {
        	                    "color": "#cccccc",
        	                    "width": 1
        	                },
        	                "crossStyle": {
        	                    "color": "#cccccc",
        	                    "width": 1
        	                }
        	            }
        	        },
        			title : {
        		        text: '政策文件统计',
        		        subtext: '',
        		        x:'left'
        		    },
        		    tooltip : {
        		        trigger: 'item',
        		        formatter: "{a} <br/>{b} : {c} ({d}%)"
        		    },
        		    legend: {
        		        orient: 'vertical',
        		        left: 'right',
        		        top:50,
        		        data: result.policyDictName,
        		    },
        		    series : [
        		        {
        		        	label: {
        		                normal: {
        		                    show: false,
        		                    position: 'center'
        		                },
        		            },
        		            name: '政策主题',
        		            type: 'pie',
        		            radius : '80%',
        		            center: ['45%', '50%'],
        		            data: result,
        		            itemStyle: {
        		                emphasis: {
        		                    shadowBlur: 10,
        		                    shadowOffsetX: 0,
        		                    borderWidth: 0,
        		                    borderColor: "#ccc",
        		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
        		                }
        		            }
        		        }
        		    ]

        	};
        	policyPie.setOption(pieOption);
        }
    });


}

/*堆叠图展示*/
/*stackedLine*/

function stackedMap(){
	$.ajax({
        url:'policy_getStacked.action',
        type:'get',
        dataType : 'json',
        success:function(list){
		var stackedLine = echarts.init(document.getElementById('stackedLine'));
		/*stackedLine.title = '堆叠图';*/
		stackedOption = {
				backgroundColor:'#f7f8fa',
				color:[
					"#c12e34",
					"#e6b600",
					"#0098d9",
					"#2b821d",
					"#005eaa",
				],

		    title: {
		        text: '政策主题数据量Top5趋势图'
		    },
		    tooltip : {
		        trigger: 'axis',
		        axisPointer: {
		            type: 'cross',
		            label: {
		                backgroundColor: '#6a7985'
		            }
		        }
		    },
		    legend: {
		        data:list.legend
		    },
		    toolbox: {
		        feature: {
		            saveAsImage: {}
		        }
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : ['一月份','二月份','三月份','四月份','五月份','六月份','七月份','八月份','九月份','十月份']
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value'
		        }
		    ],
		    series : list.result
		    /*[
		        {
		            name:'市场/行业准入',
		            type:'line',
		            stack: '总量',
		            areaStyle: {},
		            data:[30, 27, 54, 49, 24, 22, 21,4,3]
		        },
		        {
		            name:'数字化转型',
		            type:'line',
		            stack: '总量',
		            areaStyle: {},
		            data:[28,12,14,30,10,15,6,2,2]
		        },
		        {
		            name:'人才建设',
		            type:'line',
		            stack: '总量',
		            areaStyle: {normal: {}},
		            data:[4,9,13,11,13,6,7,0,0]
		        },
		        {
		            name:'企业减负',
		            type:'line',
		            stack: '总量',
		            areaStyle: {normal: {}},
		            data:[7,13,10,19,27,20,12,5,7]
		        },
		        {
		            name:'知识产权',
		            type:'line',
		            stack: '总量',
		            label: {
		            normal: {}
		        },
		            areaStyle: {normal: {}},
		            data:[11,4,8,9,3,1,1,0,0]
		        }
		    ]*/
		};

	stackedLine.setOption(stackedOption);
        }
	});
}

/*热力引导图*/
/*forceMap*/






function forceGuide(){
	var forceMap = echarts.init(document.getElementById('forceMap'));

	/*stackedLine.setOption(stackedOption);*/

	/*forceMap.title = '力引导布局';*/

	forceMap.showLoading();
	$.get('les-miserables.gexf', function (xml) {

		forceMap.hideLoading();
	    var graph = echarts.dataTool.gexf.parse(xml);
	    var categories = [];
	    /*for (var i = 0; i < 9; i++) {
	        categories[i] = {
	            name: '类目' + i
	        };
	    }*/
	    categories[0] = {
	    		color: "#005eaa",
	            name:'综合类'
	        }
	        categories[1] = {
	    		color: "#005eaa",
	            name:'创业扶持'
	        }
	        categories[2] = {
	            name:'市场准入'
	        }
	        categories[3] = {
	            name:'企业减负'
	        }
	        categories[4] = {
	            name:'公共服务'
	        }
	        categories[5] = {
	            name:'技术创新'
	        }
	        categories[6] = {
	            name:'知识产权'
	        }
	         categories[7] = {
	            name:'技术改造'
	        }
	        categories[8] = {
	            name:'数字化转型'
	        }
	        categories[9] = {
	            name:'投融资'
	        }
	         categories[10] = {
	            name:'信用担保'
	        }
	         categories[11] = {
	            name:'人才建设'
	        }
	    graph.nodes.forEach(function (node) {
	        node.itemStyle = null;
	        node.symbolSize = 20;
	        node.value = node.symbolSize;
	        node.category = node.attributes.modularity_class;
	        // Use random x, y
	        node.x = node.y = null;
	        node.draggable = true;
	    });
	    option = {
	    	backgroundColor:'#f7f8fa',
	        title: {
	            text: '政策关联图谱',
	            subtext: 'Schematic diagram of policy relevance',
	            top: 'bottom',
	            left: 'left'
	            /*top: 'top',
	            left: 'left'*/
	        },
	        tooltip: {},
	        legend: [{
	            // selectedMode: 'single',
	            data: categories.map(function (a) {
	                return a.name;
	            })
	        }],
	        animation: false,
	        series : [
	            {
	                name: '政策关系',
	                type: 'graph',
	                layout: 'force',
	                data: graph.nodes,
	                links: graph.links,
	                categories: categories,
	                roam: true,
	                label: {
	                    normal: {
	                        position: 'right'
	                    }
	                },
	                force: {
	                    repulsion: 100
	                }
	            }
	        ]
	    };
	   forceMap.setOption(option);
	}, 'xml');

}
// export default bubbleMap();
// export default pieMap();
// export default stackedMap();




